﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using QuickUIT.Controls;

namespace QuickUIT.Tests
{
    [TestClass]
    public class UIHeaderItemTests
    {
        private BaseState _baseState;

        [TestInitialize]
        public void TestSetup()
        {
            _baseState = new BaseState(TestUtilities.GetTestApplicationFileName(), "@Name='QuickUIT Test Application'");
            _baseState.Execute();
        }

        [TestMethod]
        public void ShouldGetCanResizeProperty()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIHeaderItem headerItem = window.UIDataGrid("@AutomationId='dataGrid1'").UIHeaderItem("@Name='ID'");
            Assert.IsTrue(headerItem.CanResize);
        }

        [TestMethod]
        public void ShouldResize()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIHeaderItem headerItem = window.UIDataGrid("@AutomationId='dataGrid1'").UIHeaderItem("@Name='ID'");
            headerItem.Resize(50, 20);
            Assert.AreEqual(50, headerItem.BoundingRectangle.Width);
            // TODO: width only resize method 
        }

        [TestMethod]
        public void ShouldInvoke()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            UIHeaderItem headerItem = window.UIDataGrid("@AutomationId='dataGrid1'").UIHeaderItem("@Name='ID'");
            headerItem.Invoke();
        }

        [TestMethod]
        public void ShouldGetAllHeaderItems()
        {
            var window = new UIWindow("@Name='QuickUIT Test Application'");
            List<UIHeaderItem> headerItems = window.UIDataGrid("@AutomationId='dataGrid1'").UIHeader().UIHeaderItems();
            Assert.AreEqual(4, headerItems.Count);
            Assert.AreEqual("ID", headerItems[0].Name);
            Assert.AreEqual("Name", headerItems[1].Name);
            Assert.AreEqual("Date", headerItems[2].Name);
            Assert.AreEqual("Enable", headerItems[3].Name);
        }

        [TestCleanup]
        public void TestTeardown()
        {
            _baseState.Cleanup();
        }
    }
}